package com.tdzx.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class TuanDetail {

	private String goods_id;
	private String group_id;
	private String group_name;
	private String group_context;
	private String group_price;
	private String group_imag;
	private long group_starttime;
	private long group_endtime;
	private String group_date;
	private String goods_name;
	private String group_info;
	private String group_tuangouprice;
	private String buyPeople;
	List<String> listImg = new ArrayList<String>();
	
	
	public List<String> getListImg() {
		return listImg;
	}

	public void setListImg(List<String> listImg) {
		this.listImg = listImg;
	}

	public String getBuyPeople() {
		return buyPeople;
	}

	public void setBuyPeople(String buyPeople) {
		this.buyPeople = buyPeople;
	}

	public String getGroup_tuangouprice() {
		return group_tuangouprice;
	}

	public void setGroup_tuangouprice(String group_tuangouprice) {
		this.group_tuangouprice = group_tuangouprice;
	}

	public String getGoods_name() {
		return goods_name;
	}

	public void setGoods_name(String goods_name) {
		this.goods_name = goods_name;
	}

	public String getGroup_info() {
		return group_info;
	}

	public void setGroup_info(String group_info) {
		this.group_info = group_info;
	}

	public String getGoods_id() {
		return goods_id;
	}

	public void setGoods_id(String goods_id) {
		this.goods_id = goods_id;
	}

	public String getGroup_id() {
		return group_id;
	}

	public void setGroup_id(String group_id) {
		this.group_id = group_id;
	}

	public String getGroup_name() {
		return group_name;
	}

	public void setGroup_name(String group_name) {
		this.group_name = group_name;
	}

	public String getGroup_context() {
		return group_context;
	}

	public void setGroup_context(String group_context) {
		this.group_context = group_context;
	}

	public String getGroup_price() {
		return group_price;
	}

	public void setGroup_price(String group_price) {
		this.group_price = group_price;
	}

	public String getGroup_imag() {
		return group_imag;
	}

	public void setGroup_imag(String group_imag) {
		this.group_imag = group_imag;
	}

	public long getGroup_starttime() {
		return group_starttime;
	}

	public void setGroup_starttime(long group_starttime) {
		this.group_starttime = group_starttime;
	}

	public long getGroup_endtime() {
		return group_endtime;
	}

	public void setGroup_endtime(long group_endtime) {
		this.group_endtime = group_endtime;
	}

	public String getGroup_date() {
		return group_date;
	}

	public void setGroup_date(String group_date) {
		this.group_date = group_date;
	}

	public static TuanDetail getTuanDetail(String json) {
		TuanDetail detail = null;
		try {
			JSONObject jo = new JSONObject(json);
			detail = new TuanDetail();
			detail.setGoods_id(jo.optString("goods_id"));
			detail.setGroup_context(jo.optString("group_context"));
			detail.setGroup_date(jo.optString("group_date"));
			detail.setGroup_endtime(jo.optLong("group_endtime"));
			detail.setGroup_id(jo.optString("group_id"));
			detail.setGroup_imag(jo.optString("group_imag"));
			detail.setGroup_name(jo.optString("group_name"));
			detail.setGroup_price(jo.optString("group_price"));
			detail.setGroup_starttime(jo.optLong("group_starttime"));
			detail.setGoods_name(jo.optString("goodsName"));
			detail.setGroup_info(jo.optString("group_info"));
			detail.setGroup_tuangouprice(jo.optString("group_tuangouprice"));
			detail.setBuyPeople(jo.optString("buyPeople"));
			JSONArray ja = jo.optJSONArray("listImg");
			if(ja != null) {
				for(int i = 0; i < ja.length(); i++) {
					JSONObject jo_img = ja.optJSONObject(i);
					String img = jo_img.optString("img_url");
					detail.getListImg().add(img);
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return detail;
	}
}
